﻿@using System.Security.Claims;
@using Code;

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>益健橘红茶管理系统</title>

    <environment include="Development">
        <link rel="stylesheet" href="~/layer/css/layui.css" media="all" />
        <link rel="stylesheet" href="~/layer/css/admin.css" media="all" />
    </environment>
    <environment exclude="Development">
        <link rel="stylesheet" href="~/layer/css/layui.css" asp-append-version="true" media="all" />
        <link rel="stylesheet" href="~/layer/css/admin.css" asp-append-version="true" media="all" />
    </environment>
</head>
<body class="layui-layout-body">

    <div id="LAY_app">
        <div class="layui-layout layui-layout-admin">
            <div class="layui-header">
                <!-- 头部区域 -->
                <ul class="layui-nav layui-layout-left">
                    <li class="layui-nav-item layadmin-flexible" lay-unselect>
                        <a href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
                            <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
                        </a>
                    </li>
                    <li class="layui-nav-item layui-hide-sm" lay-unselect>
                        <a href="javascript:;">
                            益健橘红茶
                        </a>
                    </li>
                </ul>
                <ul class="layui-nav layui-layout-right" lay-filter="layadmin-layout-right">
                    <li class="layui-nav-item layui-hide-xs" lay-unselect>
                        <a href="javascript:;" layadmin-event="note">
                            <i class="layui-icon layui-icon-note"></i>
                        </a>
                    </li>
                    <li class="layui-nav-item layui-hide-xs" lay-unselect>
                        <a href="javascript:;" layadmin-event="fullscreen">
                            <i class="layui-icon layui-icon-screen-full"></i>
                        </a>
                    </li>
                    <li class="layui-nav-item" lay-unselect>
                        <a href="javascript:;">
                            <cite>@ViewData["Name"]</cite>
                        </a>
                        <dl class="layui-nav-child">
                            <dd><a lay-href="@Url.Action("changepassword","account",new { userType = ViewData["userType"]})">修改密码</a></dd>
                            @if ((string)ViewData["userType"] == ((int)Code.UserTypes.普通用户).ToString()) {
                                <dd><a lay-href="@Url.Action("secondarypwd", "account", new { Id = ViewData["Id"]  })">修改二级密码</a></dd>
                                <hr />
                                <dd><a lay-href="@Url.Action("detail", "account", new { Id = ViewData["Id"]  })">个人资料</a></dd>
                            }
                            <hr />
                            <dd style="text-align: center;"><a href="@Url.Action("logout","api")">退出</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>

            <!-- 侧边菜单 -->
            <div class="layui-side layui-side-menu">
                <div class="layui-side-scroll">
                    <div class="layui-logo" lay-href="home/console.html">
                        <span>益健橘红茶</span>
                    </div>

                    <ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu" lay-filter="layadmin-system-side-menu">
                        @if ((string)ViewData["userType"] == ((int)Code.UserTypes.普通用户).ToString()) {
                            <li data-name="user" class="layui-nav-item">
                                <a href="javascript:;" lay-tips="用户" lay-direction="2">
                                    <i class="layui-icon layui-icon-user"></i>
                                    <cite>账户管理</cite>
                                </a>
                                <dl class="layui-nav-child">
                                    <dd>
                                        <a lay-href="@Url.Action("recommend", "account")">推荐会员</a>
                                    </dd>
                                    <dd>
                                        <a lay-href="@Url.Action("recommendlist", "account")">推荐机构</a>
                                    </dd>
                                </dl>
                            </li>

                            <li data-name="user" class="layui-nav-item">
                                <a href="javascript:;" lay-tips="商城" lay-direction="2">
                                    <i class="layui-icon layui-icon-cart"></i>
                                    <cite>购物商城</cite>
                                </a>
                                <dl class="layui-nav-child">
                                    <dd>
                                        <a lay-href="@Url.Action("productinfo", "order")">购买商品</a>
                                    </dd>
                                    <dd>
                                        <a lay-href="@Url.Action("list", "order")">订单列表</a>
                                    </dd>
                                </dl>
                            </li>

                            <li data-name="user" class="layui-nav-item">
                                <a href="javascript:;" lay-tips="财务" lay-direction="2">
                                    <i class="layui-icon layui-icon-dollar"></i>
                                    <cite>财务管理</cite>
                                </a>
                                <dl class="layui-nav-child">
                                    <dd>
                                        <a lay-href="@Url.Action("incomelist", "finance")">收入明细</a>
                                    </dd>
                                    <dd>
                                        <a lay-href="@Url.Action("cashloglist", "finance")">提现记录</a>
                                    </dd>
                                </dl>
                            </li>

                            <li data-name="get" class="layui-nav-item">
                                <a href="javascript:;" lay-href="@Url.Action("list", "notice")" lay-tips="交流公告" lay-direction="2">
                                    <i class="layui-icon layui-icon-list"></i>
                                    <cite>交流公告</cite>
                                </a>
                            </li>
                        } else {
                            if (ViewBag.Menus != null) {
                                var menus = ViewBag.Menus as List<Models.Area>;

                                if (menus.FirstOrDefault(m => m.id == 1) != null) {
                                    <li data-name="get" class="layui-nav-item">
                                        <a href="javascript:;" lay-href="@Url.Action("Product", "Home")" lay-tips="商品编辑" lay-direction="2">
                                            <i class="layui-icon layui-icon-form"></i>
                                            <cite>商品编辑</cite>
                                        </a>
                                    </li>
                                }


                                if (menus.FirstOrDefault(m => m.id == 2) != null) {
                                    <li data-name="get" class="layui-nav-item">
                                        <a href="javascript:;" lay-href="@Url.Action("list", "order")" lay-tips="商城订单" lay-direction="2">
                                            <i class="layui-icon layui-icon-cart"></i>
                                            <cite>商城订单</cite>
                                        </a>
                                    </li>
                                }


                                if (menus.Count(m => m.parent == 3) > 0) {
                                    <li data-name="user" class="layui-nav-item">
                                        <a href="javascript:;" lay-tips="用户" lay-direction="2">
                                            <i class="layui-icon layui-icon-user"></i>
                                            <cite>用户</cite>
                                        </a>
                                        <dl class="layui-nav-child">

                                            @if (menus.FirstOrDefault(m => m.id == 4) != null) {
                                                <dd>
                                                    <a lay-href="@Url.Action("list", "account", new { userTypes = (int)UserTypes.普通用户 })">推荐机构</a>
                                                </dd>
                                            }

                                            @if (menus.FirstOrDefault(m => m.id == 5) != null) {
                                                <dd>
                                                    <a lay-href="@Url.Action("list", "account", new { userTypes = (int)UserTypes.管理员 })">后台用户管理</a>
                                                </dd>
                                            }

                                            @if (menus.FirstOrDefault(m => m.id == 6) != null) {
                                                <dd>
                                                    <a lay-href="@Url.Action("roles", "account")">角色管理</a>
                                                </dd>
                                            }
                                        </dl>
                                    </li>
                                }

                                if (menus.Count(m => m.parent == 7) > 0) {
                                    <li data-name="user" class="layui-nav-item">
                                        <a href="javascript:;" lay-tips="财务" lay-direction="2">
                                            <i class="layui-icon layui-icon-dollar"></i>
                                            <cite>财务管理</cite>
                                        </a>
                                        <dl class="layui-nav-child">

                                            @if (menus.FirstOrDefault(m => m.id == 8) != null) {
                                                <dd>
                                                    <a lay-href="@Url.Action("incomelist", "finance")">收入明细</a>
                                                </dd>
                                            }

                                            @if (menus.FirstOrDefault(m => m.id == 9) != null) {
                                                <dd>
                                                    <a lay-href="@Url.Action("cashloglist", "finance")">提现记录</a>
                                                </dd>
                                            }

                                            @if (menus.FirstOrDefault(m => m.id == 10) != null) {
                                                <dd>
                                                    <a lay-href="@Url.Action("info", "charts")">统计报表</a>
                                                </dd>
                                            }
                                        </dl>
                                    </li>
                                }

                                if (menus.FirstOrDefault(m => m.id == 11) != null) {
                                    <li data-name="get" class="layui-nav-item">
                                        <a href="javascript:;" lay-href="@Url.Action("list", "notice")" lay-tips="交流公告" lay-direction="2">
                                            <i class="layui-icon layui-icon-list"></i>
                                            <cite>交流公告</cite>
                                        </a>
                                    </li>
                                }

                                if (menus.Count(m => m.parent == 12) > 0) {
                                    <li data-name="user" class="layui-nav-item">
                                        <a href="javascript:;" lay-tips="系统" lay-direction="2">
                                            <i class="layui-icon layui-icon-set-sm"></i>
                                            <cite>系统设置</cite>
                                        </a>
                                        <dl class="layui-nav-child">


                                            @if (menus.FirstOrDefault(m => m.id == 13) != null) {
                                                <dd>
                                                    <a lay-href="@Url.Action("noticeedit", "notice", new { type = (int)Code.NoticeType.购买协议 })">购买协议</a>
                                                </dd>
                                            }


                                            @if (menus.FirstOrDefault(m => m.id == 14) != null) {
                                                <dd>
                                                    <a lay-href="@Url.Action("receipt", "setting")">收款信息</a>
                                                </dd>
                                            }
                                        </dl>
                                    </li>
                                }
                            }
                        }
                    </ul>
                </div>
            </div>

            <!-- 页面标签 -->
            <div class="layadmin-pagetabs" id="LAY_app_tabs">
                <div class="layui-icon layadmin-tabs-control layui-icon-prev" layadmin-event="leftPage"></div>
                <div class="layui-icon layadmin-tabs-control layui-icon-next" layadmin-event="rightPage"></div>
                <div class="layui-icon layadmin-tabs-control layui-icon-down">
                    <ul class="layui-nav layadmin-tabs-select" lay-filter="layadmin-pagetabs-nav">
                        <li class="layui-nav-item" lay-unselect>
                            <a href="javascript:;"></a>
                            <dl class="layui-nav-child layui-anim-fadein">
                                <dd layadmin-event="closeThisTabs"><a href="javascript:;">关闭当前标签页</a></dd>
                                <dd layadmin-event="closeOtherTabs"><a href="javascript:;">关闭其它标签页</a></dd>
                                <dd layadmin-event="closeAllTabs"><a href="javascript:;">关闭全部标签页</a></dd>
                            </dl>
                        </li>
                    </ul>
                </div>
                <div class="layui-tab" lay-unauto="false" lay-allowClose="true" lay-filter="layadmin-layout-tabs">
                    <ul class="layui-tab-title" id="LAY_app_tabsheader">
                        <li lay-id="@Url.Action("about","home")" lay-attr="" class="layui-this"><i class="layui-icon layui-icon-home"></i></li>
                    </ul>
                </div>
            </div>


            <!-- 主体内容 -->
            <div class="layui-body" id="LAY_app_body">
                <div class="layadmin-tabsbody-item layui-show">
                    @RenderBody()
                    <iframe src="@Url.Action("about","home")" frameborder="0" class="layadmin-iframe"></iframe>
                </div>
            </div>

            <!-- 辅助元素，一般用于移动设备下遮罩 -->
            <div class="layadmin-body-shade" layadmin-event="shade"></div>
        </div>
    </div>
    <script src="~/layer/layui.js"></script>
    <script>
        layui.config({
            base: '../../layer/' //静态资源所在路径
        }).extend({
            index: 'index' //主入口模块
        }).use(['index', "admin"], function () {
            var $ = layui.$
                , admin = layui.admin
                , element = layui.element;

            element.on('tab(layadmin-layout-tabs)', function () {
                var url = this.getAttribute('lay-id');
                var iframe = admin.tabsBody(admin.tabsPage.index).find(".layadmin-iframe");

                if (url !== "") {
                    iframe[0].contentWindow.location.href = url;
                }
            });

            var _tool = {
                alert: function (message, icon, callback) {
                    layer.alert(message, { offset: '15px', icon: icon }, function (index) {
                        callback && typeof (callback) === 'function' && callback(index);
                        layer.closeAll();
                    });
                },
                msg: function (message, option, callback, loadIndex) {
                    layer.msg(message, option, function (index) {
                        callback && typeof (callback) === 'function' && callback(index, loadIndex);
                        //layer.closeAll();
                    });
                },
                confirm: function (message, callback) {
                    layer.confirm(message, function (index) {
                        callback && typeof (callback) === 'function' && callback(index);

                        layer.close(index);
                    });
                },
                load: function (icon, option) {
                    return layer.load(icon, option);
                },
                close: function (index) {
                    layer.close(index);
                },
                closeAll: function () {
                    layer.closeAll();
                },
                open: function (element, title, btns, area, callbackParam, callback, btn2CallBack, closeBtn) {
                    var option = {
                        type: 1,
                        title: title,
                        shade: 0.8,
                        content: element,
                        btn: btns,
                        btnAlign: 'c',
                        yes: function (index) {
                            var callbackValue = {};
                            if (callbackParam != null) {
                                callbackParam.forEach(function (item) {
                                    callbackValue[item] = $('#' + item).val();
                                });
                            }
                            callback && typeof (callback) === 'function' && callback(index, callbackValue);
                            //layer.close(layerindex);
                        },
                        btn2: function (index) {
                            var callbackValue = {};
                            if (callbackParam != null) {
                                callbackParam.forEach(function (item) {
                                    callbackValue[item] = $('#' + item).val();
                                });
                            }
                            btn2CallBack && typeof (btn2CallBack) === 'function' && btn2CallBack(index, callbackValue);
                        }
                    };

                    if (area != null) option['area'] = area;
                    if (closeBtn != undefined) option['closeBtn'] = closeBtn;

                    layerindex = layer.open(option);
                },
                photos: function (src, alt) {
                    layer.photos({
                        photos: {
                            "title": "", //相册标题
                            "id": 123, //相册id
                            "start": 0, //初始显示的图片序号，默认0
                            "data": [   //相册包含的图片，数组格式
                                {
                                    "alt": alt,
                                    "pid": 666, //图片id
                                    "src": src, //原图地址
                                    "thumb": "" //缩略图地址
                                }
                            ]
                        }
                        , anim: 5
                    });
                }
            }

            window.tools = _tool;
        });
    </script>
</body>
</html>

